import { AttrType } from "../attr/AttrType";
import { TriggerMgr } from "../trigger/TriggerMgr";
import { RoleAttrMgr } from "./mgr/RoleAttrMgr";
import { RoleBuffMgr } from "./mgr/RoleBuffMgr";
import { RoleSkillMgr } from "./mgr/RoleSkillMgr";
import { RoleData } from "./RoleData";

/**
 * 战斗单位逻辑类（包含数据）
 */
export class BattleRole {

    private _roleData: RoleData;

    private _skillMgr: RoleSkillMgr;

    private _buffMgr: RoleBuffMgr;

    private _attrMgr: RoleAttrMgr;

    private _equipMgr: any;

    private _triggerMgr: TriggerMgr;

    public uid: string;

    init(roleData: RoleData) {
        this._roleData = roleData;
        this.uid = roleData.uid;
        this._attrMgr = new RoleAttrMgr();
        this._attrMgr.init(roleData.attrData);

        this._skillMgr = new RoleSkillMgr();
        this._skillMgr.init(roleData.skillData);

        //buff来源-被动技能、装备、玩家特性
        this._buffMgr = new RoleBuffMgr();
        this._buffMgr.init();

        this._triggerMgr = new TriggerMgr();
    }

    /**是否存活 */
    isAlive(): boolean {
        return this._attrMgr.getAttr(AttrType.hp) > 0;
    }

    public get roleData(): RoleData {
        return this._roleData
    }

    public get attrMgr(): RoleAttrMgr {
        return this._attrMgr;
    }

    public get skillMgr(): RoleSkillMgr {
        return this._skillMgr;
    }

    public get triggerMgr(): TriggerMgr {
        return this._triggerMgr;
    }

    public get buffMgr(): RoleBuffMgr {
        return this._buffMgr
    }
}